package controller;

import model.User;
import web.annotation.Method;
import web.annotation.Param;
import web.annotation.Type;
import web.jdbc.QuerySQL;
import web.util.RetrunResult;

@Type("loginController")
public class LoginController {
	QuerySQL<User> qs = new QuerySQL<>();
	
	

	@Method(value="login",isReturnPage = true)
	public RetrunResult login(@Param("username")String username,@Param("password")String password){
		RetrunResult rr = new  RetrunResult();
		rr.setPage("WEB-INF/page/ProductAdd.jsp");
		return rr ;
	}
	
	@Method(value="register",isReturnPage = true)
	public RetrunResult register(@Param("user")User user){
		RetrunResult rr = new  RetrunResult();
		if(qs.insertData(user)) {
			rr.setMassage("注册成功！");
		}else {
			rr.setMassage("注册失败！");
		}
		rr.setPage("WEB-INF/page/login.jsp");
		return rr;
	}
	
	
}
